
package nccloud.web.arap.amortization.action;

import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.arap.amortization.AggAmortizationVO;
import nc.vo.pub.BusinessException;
import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.itf.arap.amortization.aggamortizationvo.IAmortizationvoService;
import nccloud.pubitf.platform.query.INCCloudQueryService;
import nccloud.web.arap.amortization.utils.ResultUtil;

/**
* @description 一主多子查询
* @version ncc1.0
**/
public class QueryAction implements ICommonAction {
    /**
    * 列表模板编码
    */
    public static final String PAGECODE_LIST = "20060794_list";

    @Override
    public Object doAction(IRequest request) {
        String read = request.read();
        IJson json = JsonFactory.create();
        QueryTreeFormatVO formatVO = json.fromJson(read, QueryTreeFormatVO.class);

        // 获取查询模板查询条件
        INCCloudQueryService queryutil = ServiceLocator.find(INCCloudQueryService.class);
        IQueryScheme queryScheme = queryutil.convertCondition(formatVO);
        try {
            AggAmortizationVO[] aggVOs = ServiceLocator.find(IAmortizationvoService.class).queryByQueryScheme(queryScheme);
            return ResultUtil.convertBillsToGrid(aggVOs, PAGECODE_LIST);
        } catch (BusinessException e) {
            ExceptionUtils.wrapException(e);
        }
        return null;
    }

}
